﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace eCRAM.Model
{
    public partial class Cram
    {
        public CramStatus Status
        {
            get
            {
                if (CramLines.All(l => l.Status == (int)CramStatus.New)) return CramStatus.New;
                if (CramLines.All(l => l.Status == (int)CramStatus.Submit)) return CramStatus.Submit;
                if (CramLines.All(l => l.Status == (int)CramStatus.Validated)) return CramStatus.Validated;
                if (CramLines.All(l => l.Status == (int)CramStatus.Approved)) return CramStatus.Approved;
                if (CramLines.All(l => l.Status == (int)CramStatus.Submit || l.Status == (int)CramStatus.Validated))
                    return CramStatus.PartialValidated;
                return CramStatus.PartialApproved;
            }
        }
    }
}
